<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="com.bci.pwtz.common.util.PwtzUtils"%>
<%@page import="com.bci.pwtz.mysql.model.BatchUpdate"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/user/common.jsp"%>
<%@ page import="com.bci.pwtz.common.util.SpringUtil" %>
<%@ page import="com.bci.pwtz.service.ConfigService" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String devicetype = request.getParameter("devicetype");
String[] deviceids = request.getParameterValues("deviceid");
String[] devicenames = request.getParameterValues("devicename");
List<BatchUpdate> infos = PwtzConstants.BATCH_UPDATE.get(devicetype);
String deviceTypeName = PwtzConstants.DEVICE_TYPE_MAP.get(PwtzUtils.passLong(devicetype));
String referer = request.getHeader("Referer");
if(referer == null){
	referer = basePath+"user/m/index.jsp";
}
pageContext.setAttribute("referer",referer);
pageContext.setAttribute("infos",infos);
pageContext.setAttribute("deviceTypeName",deviceTypeName);
pageContext.setAttribute("deviceids",deviceids);
pageContext.setAttribute("devicenames",devicenames);
Long companyId=null;
if(user!=null){
    companyId=user.getLastCompanyId();
}
ConfigService configService=(ConfigService)SpringUtil.getBean("configService");
String picpath=configService.getConfigByKey("DevicePICPath");

if(deviceTypeName == null){//未获取到信息重定向到首页
	response.sendRedirect("/pwtz/user/m/index.jsp");
	return;
}
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>配网数据-<%=deviceTypeName %></title>
<link href="<%=basePath %>user/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>user/css/llcss.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="<%=basePath %>js/jquery/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=basePath %>js/toolutils.js"></script>
<script type="text/javascript" src="<%=basePath %>js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=basePath %>user/js/hd_ll.js"></script>
<script type="text/javascript" src="<%=basePath %>user/js/common.js"></script>
<script type="text/javascript" src="<%=basePath %>js/ajaxfileupload.js"></script>
<script type="text/javascript">
var companyId=<%=companyId%>;
var picpath='<%=picpath%>';
var referer = '${referer}';
var model,productionfactory,towerheight,wirespecification,ratedcapacity;
</script>
<script type="text/javascript" src="<%=basePath %>user/js/batchupdate.js"></script>
</head>
<body bgcolor="white">
	<%@ include file="/user/head.jsp"%>
	<!-- main_begin -->
	<div class="pwsj_cont_box">
	<%@ include file="/user/left.jsp"%>
	<!-- 右侧内容_begin -->
	<form id="form">
		<input type="hidden" name="devicetype" value="<%=devicetype%>"/>
		<c:forEach items="${deviceids }" var="deviceid">
			<input type="hidden" name="deviceid" value="${deviceid }" />
		</c:forEach>
		<c:forEach items="${devicenames }" var="devicename">
			<input type="hidden" name="devicename" maxlength="100" value="${devicename }" />
		</c:forEach>
		<div class="pwsj_cont_right_box" scroll="no">
		<!-- 变电站_begin -->
		<div class="pwsj_right_byq" scroll="no">
			<div class="pwsj_right_byq_position" style="margin-bottom:3px;">
				<a  class="position">配网数据</a>&gt;<a  class="position">${deviceTypeName }</a>
				<a class="right" href="${referer }">返回</a><a class="right"  onclick="batchupdate()">保存</a>
			</div>
			<!-- 运行参数_begin -->
			<div class="argument_box">
				<!-- 参数标题-begin -->
				<div class="argument_title">
					<p class="title">批量修改信息</p>
					<a  class="show"></a>
					<div class="clear"></div>
				</div>				
				<!-- 参数标题-end -->
				<!-- 参数内容_begin -->
				<div class="argument_cont_box">
					<c:forEach items="${infos }" var="info" varStatus="status">
						<%--每隔3条记录换行 --%>
						<c:if test="${(status.index+1) % 3 == 1 }">
							<ul class="argument_cont_ul">
						</c:if>
						<li class="argument_cont_li">
							<input class="chooseColumn" type="checkbox" name="chooseColumn" value="${info.column }"/>
							<span>${info.columnname }：</span>
							<c:choose>
								<%--如果该值为空代表为手动输入 --%>
								<c:when test="${empty info.selectcontent }">
									<c:set var="dateType" value=""></c:set>
									<%--如果为日期，则添加日期控件 --%>
									<c:if test="${fn:endsWith(info.column,'Date') }">
										<c:set var="dateType" value="onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" placeholder='请选择日期'"></c:set>
									</c:if>
									<input class="text" type="text" name="${info.column }" ${dateType }/>
									<c:if test="${!empty dateType}">
										<img width='16' height='16' style='position:relative; top:3px;left:-30px;' src='images/select_date.jpg'>
									</c:if>
								</c:when>
								<%--下拉列表 --%>
								<c:otherwise>
									<select class="select_down" name="${info.column }" id="${fn:toLowerCase(info.column) }">
										<c:set var="isDictionary" value="${info.column == 'Model' ||  info.column == 'ProductionFactory' || info.column == 'TowerHeight' || info.column == 'WireSpecification'}"></c:set>
										<c:set var="typeid" value=""></c:set>
										<c:if test="${isDictionary }"><%--字典 --%>
											<c:set var="typeid" value="${info.selectcontent }"></c:set>
										</c:if>
										<c:if test="${!isDictionary }"><%--非字典，选择框 --%>
											<c:forEach items="${fn:split(info.selectcontent,'#') }" var="option">
												<option value="${option }">${option }</option>
											</c:forEach>
										</c:if>
									</select>
									<c:if test="${isDictionary }"><%--字典 --%>
										<a onclick="dictionaryadd('${info.columnname}',${typeid },this)" title="手动输入"><img alt="" src="images/transformer_img_add.png"></a>
										<script>dictionaryStart('${fn:toLowerCase(info.column) }','${typeid }');</script>
									</c:if>
								</c:otherwise>
							</c:choose>
						</li>
						<c:set var="len" value="${fn:length(infos) }"></c:set>
						<c:if test="${(status.index+1) % 3 == 0 || status.index==len-1 }">
								<div class="clear"></div>
							</ul>
						</c:if>
					</c:forEach>
					<ul class="argument_cont_ul">
						<li class="argument_cont_li">
							<input id="chooseAll" type="checkbox" onclick="$('.chooseColumn').attr('checked',this.checked)" />
							<label for="chooseAll">全选</label> 
						</li>
						<div class="clear"></div>
					</ul>
				</div>
				<!-- 参数内容_end -->
			</div>
			<!-- 运行参数_end -->
		</div>	
		<!-- 变电站_end -->		
	</div>
	</form>
	<!-- 右侧内容_end -->
	<div class="clear"></div><!-- 清除左右浮动 -->
	</div>
	<!-- main_end -->
	<%@ include file="/user/foot.jsp"%>
</body>
</html>